package com.banzhi.shop.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.banzhi.shop.R;
import com.banzhi.shop.adapter.CollegeOrderAdapter;
import com.banzhi.shop.base.BaseActivity;
import com.banzhi.shop.fragment.VIPOrderFragment;
import com.banzhi.shop.fragment.VideoOrderFragment;
import com.banzhi.shop.utils.TabLayoutUtil;
import com.banzhi.shop.utils.Translucent;

import java.util.ArrayList;
import java.util.List;

//学院订单
public class CollegeOrderActivity extends BaseActivity implements View.OnClickListener {

    private ImageView mIvBack;
    private TabLayout mTabs;
    private ViewPager mViewpager;
    private CollegeOrderAdapter mCollegeOrderAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_college_order);
        Translucent.setTranslucent(this);
        initView();
        initListener();
        showFragment();

    }

    @Override
    protected void onStart() {
        super.onStart();
        mTabs.post(new Runnable() {
            @Override
            public void run() {
                TabLayoutUtil.setIndicator(mTabs, 20, 20);
            }
        });
    }

    private void showFragment() {
        List<Fragment> fragments = new ArrayList<>();
   /*     fragments.add(new GoodsIntroductionFrg());//商品介绍
        fragments.add(new GoodsParameterFrg());//详情参数*/
        fragments.add(new VideoOrderFragment());
        fragments.add(new VIPOrderFragment());
        List<String> titles = new ArrayList<>();
        titles.add("视频订单");
        titles.add("VIP订单");

   //     HomeFrgAda hfadapter = new HomeFrgAda(getSupportFragmentManager(), fragments, titles);
        mCollegeOrderAdapter = new CollegeOrderAdapter(getSupportFragmentManager(), fragments, titles);
        mViewpager.setAdapter( mCollegeOrderAdapter);
        //将tabLayout与viewpager连起来
        mTabs.setupWithViewPager(mViewpager);

    }

    private void initView() {
        mIvBack = (ImageView) findViewById(R.id.iv_back);
        mTabs = (TabLayout) findViewById(R.id.tab);
        mViewpager = (ViewPager) findViewById(R.id.viewpager);

    }

    private void initListener() {
        mIvBack.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;

        }
    }
}
